import React, { useState, useEffect } from 'react'


export default function App() {
  const [count, setCount] = useState(0)
  const [isHot, setIsHot] = useState(true)

  useEffect(() => {
    console.log("isHot,count执行了");
    return () => {
      console.log("isHot,count的卸载函数" + count);
    }
  }, [count, isHot])

  return (
    <div>
      <h1>累加的值为:{count}</h1>
      <button onClick={() => { setCount(count + 1) }}>点击累加</button>
      <hr />
      <h2>今天的天气真{isHot ? "热啊" : "冷啊"}</h2>
      <button onClick={() => { setIsHot(!isHot) }}>点击切换天气</button>
    </div>
  )
}
